Intro to QGIS | KMFRI, Kisumu
Phil Taylor, CEH

March 2019

Resources

Below are some notes & videos on the tasks we went over in the training course.

Tutorials

There are lots of online tutorials, with the following lessons covering a similar scope to content below:

We also worked with the Print Layout to produce a map output. This guide starts with the same procedure, then shows how this output can be automated:

Kenya Data

For the course in Kisumu, we used the following data:

Tutorial Data

The following workflow mirrors what we worked on in Kisumu, and uses a specifically-designed training dataset set in Fiji. This dataset can be downloaded here.

Import Data (.csv)

We’re starting off by importing the CSV file of point locations. Before importing a similar CSV, you need to be aware of these three things:

  • The x coordinate column (such as ‘longitude’)
  • The y cooridnate column (such as ‘latitude’)
  • The projection of these coordinates (such as ‘WGS 84’)

Projections are often referred to by their EPSG code. You can look up these codes and search for projections on epsg.io. As with all data importing, we start by going to Layer > Add Layer, and for CSV files we select ‘Add Delimited Text Layer..’

  • For points, lines and polygons we would select ‘Add Vector Layer..’
  • For gridded data we would select ‘Add Raster Layer..’

Importing CSV Data

Export Data (.gpkg)

The imported points are just a temporary layer in QGIS, so it’s a good idea to export them. Here we’re doing so as a GeoPackage (single file), but you can equally choose ‘ESRI Shapefile’ in the Format drop-down box - this is a proprietary, but widely used, format - it saves as multiple files. If you select ‘Add saved file to map’ then you can skip the re-import step. Otherwise, go to Layer > Add Layer > Add Vector Layer… and select your saved file.

Exporting GeoPackage Data

Background Maps

In order to easily add background maps, we can install the QuickMapServices plugin. This is just the start, however! There are lots more map options available in the plugin’s settings, and XYZ tiles can be added for even more possibilities. This guide shows you how.

Adding a Background Map

Thematic Classes

Points can easily be styled based on their attributes. In this example we are categorising based on a text field, giving each category a different coloured point. Right-click on the layer and go to Properties, then in the Symbology tab, select ‘Categorised’ in the top menu. From here, you just need to select the column of data (the attribute) you’d like to classify, then a preferred colour ramp. Once these have been selected, the ‘classify’ button below will style your points as desired.

Categorising Text

Editing Attributes

Categorising data can be an easy way to see if there are any errors in a dataset. The video above showed a category for ‘Turtles’ as well as one for ‘Turtels’. This latter category is due to an error in the dataset, where the ‘Research Activity’ has been misspelled. The principle for editing any value is exactly the same.

Start by right-clicking on the layer and go to ‘Open Attribute Table’. You then need to click the Editing button (pencil) to allow attribute editing. Then you can simply click on the value you want to change and type in the correct one. Clicking the pencil again will stop editing mode and you will be asked to save your edits. The data can then be re-classified with the correct thematic classes using the guide above.

NB If you are editing data, it is a good idea to have the ‘Digitizing Toolbar’ added to QGIS. You can add this by right-clicking on any blank space in the top menus, then selecting it from the options. You’ll see some new buttons have been added to the top menu, which allow easy editing of spatial data and attributes - the video below shows how to add this toolbar, edit data and re-classify it:

Editing Attributes

Numeric Classes

Instead of categorising the data, we can also use numeric data to change the colour or size of the points. This is good for showing information on the scale of an attribute as well as its point location.

By colour

We can use numeric data to change the colour of the point - this is generally most useful when using one colour and changing its brightness (so small values are, say, light red, and large values are dark red).

Start by right-clicking on the layer and selecting Properties. Then in the Symbology tab, this time choose ‘Graduated’ in the top menu. You can select any column with numeric data, then in the ‘Method’ box, choose ‘Color’. Select a sensible color ramp, then choose your desired amount of classes in the ‘Classes’ box below, before pressing the ‘Classify’ button to see the result.

Categorising Numbers: Colour

By size

We can also use numeric data to change the size of the point - this is a very visual way to show the range in numeric values.

Start by right-clicking on the layer and selecting Properties. Then in the Symbology tab, again choose ‘Graduated’ in the top menu. You can select any column with numeric data, then in the ‘Method’ box, choose ‘Size’. Designate the range of sizes you want the points to be in the ‘Size from’ boxes, then choose your desired amount of classes in the ‘Classes’ box below, before pressing the ‘Classify’ button to see the result.

Categorising Numbers: Size

Creating a Map in Print Layout

Once we were happy with how we’d styled our points and added a background map, we explored using ‘Print Layout’ (NB this was previously called ‘Print Composer’) to create outputs for publication. We styled our map with a legend, scale, north arrow and graticules, but there are many more options available. This guide shows how to add some of these features and exports the map to a suitable image format.

Using Print Layout

3D Visualisations with qgis2threejs

Finally, we explored some more advanced QGIS features, such as using our DTM to create a 3D terrain map of the area around Kisumu, as well as displaying some of our data points as towers based on their values. You can see the output of this work here.

If you’d like to learn more about using this plugin and creating some 3D outputs, then this excellent tutorial goes through the basic steps necessary.